﻿namespace HRM.CORE
{

    using APP.HELPER.Data.Helper;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data.SqlClient;

    public class HRM_INSURANCE_DECLARATION
    {
        private string m_DeclarationCode;
        private string m_Description;
        private string m_EmployeeCode;
        private string m_Interest;
        private int m_Status;

        public HRM_INSURANCE_DECLARATION()
        {
            this.m_DeclarationCode = "";
            this.m_EmployeeCode = "";
            this.m_Status = 0;
            this.m_Interest = "";
            this.m_Description = "";
        }

        public HRM_INSURANCE_DECLARATION(string DeclarationCode, string EmployeeCode, int Status, string Interest, string Description)
        {
            this.m_DeclarationCode = DeclarationCode;
            this.m_EmployeeCode = EmployeeCode;
            this.m_Status = Status;
            this.m_Interest = Interest;
            this.m_Description = Description;
        }

        public string Delete(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_INSURANCE_DECLARATION_Delete", myParams, myValues);
        }

        public bool Exist(string DeclarationCode)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@DeclarationCode" };
            object[] myValues = new object[] { DeclarationCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_INSURANCE_DECLARATION_Exist", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public bool ExistEmployeeCode(string EmployeeCode)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_INSURANCE_DECLARATION_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(string EmployeeCode)
        {
            string str = "";
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_INSURANCE_DECLARATION_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_DeclarationCode = Convert.ToString(reader["DeclarationCode"]);
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    this.m_Interest = Convert.ToString(reader["Interest"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, string EmployeeCode)
        {
            string str = "";
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_INSURANCE_DECLARATION_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_DeclarationCode = Convert.ToString(reader["DeclarationCode"]);
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    this.m_Interest = Convert.ToString(reader["Interest"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, string EmployeeCode)
        {
            string str = "";
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_INSURANCE_DECLARATION_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_DeclarationCode = Convert.ToString(reader["DeclarationCode"]);
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    this.m_Interest = Convert.ToString(reader["Interest"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string NewID()
        {
            return SqlHelper.GenCode("HRM_INSURANCE_DECLARATION", "DeclarationCode", "DC");
        }

        public string Update()
        {
            string[] myParams = new string[] { "@DeclarationCode", "@EmployeeCode", "@Status", "@Interest", "@Description" };
            object[] myValues = new object[] { this.m_DeclarationCode, this.m_EmployeeCode, this.m_Status, this.m_Interest, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_INSURANCE_DECLARATION_Update", myParams, myValues);
        }

        public string Update(string DeclarationCode, string EmployeeCode, int Status, string Interest, string Description)
        {
            string[] myParams = new string[] { "@DeclarationCode", "@EmployeeCode", "@Status", "@Interest", "@Description" };
            object[] myValues = new object[] { DeclarationCode, EmployeeCode, Status, Interest, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_INSURANCE_DECLARATION_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, string DeclarationCode, string EmployeeCode, int Status, string Interest, string Description)
        {
            string[] myParams = new string[] { "@DeclarationCode", "@EmployeeCode", "@Status", "@Interest", "@Description" };
            object[] myValues = new object[] { DeclarationCode, EmployeeCode, Status, Interest, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_INSURANCE_DECLARATION_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, string DeclarationCode, string EmployeeCode, int Status, string Interest, string Description)
        {
            string[] myParams = new string[] { "@DeclarationCode", "@EmployeeCode", "@Status", "@Interest", "@Description" };
            object[] myValues = new object[] { DeclarationCode, EmployeeCode, Status, Interest, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_INSURANCE_DECLARATION_Update", myParams, myValues);
        }

        [DisplayName("DeclarationCode"), Category("Primary Key")]
        public string DeclarationCode
        {
            get
            {
                return this.m_DeclarationCode;
            }
            set
            {
                this.m_DeclarationCode = value;
            }
        }

        [Category("Column"), DisplayName("Description")]
        public string Description
        {
            get
            {
                return this.m_Description;
            }
            set
            {
                this.m_Description = value;
            }
        }

        [DisplayName("EmployeeCode"), Category("Column")]
        public string EmployeeCode
        {
            get
            {
                return this.m_EmployeeCode;
            }
            set
            {
                this.m_EmployeeCode = value;
            }
        }

        [DisplayName("Interest"), Category("Column")]
        public string Interest
        {
            get
            {
                return this.m_Interest;
            }
            set
            {
                this.m_Interest = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_INSURANCE_DECLARATION";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [Category("Column"), DisplayName("Status")]
        public int Status
        {
            get
            {
                return this.m_Status;
            }
            set
            {
                this.m_Status = value;
            }
        }
    }
}

